/// @tags:
#include <cstdio>
#include <functional>
#include <iostream>
#include <numeric>

using std::cin, std::cout, std::endl;

namespace BlueQuantum {

constexpr int maxn = 1e2 + 5, maxm = maxn * maxn / 2;
int ecnt;
int heads[maxn];

struct Edge {
  int v, nxt;
} e[maxm * 2];

inline void add(int u, int v) {
  e[++ecnt].v = v, e[ecnt].nxt = heads[u], heads[u] = ecnt;
}

bool vis[maxn];

void dfs(int u) {
  vis[u] = true;
  for (int i = heads[u]; i; i = e[i].nxt) {
    if (!vis[e[i].v]) dfs(e[i].v);
  }
}

int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    int u, v;
    cin >> u >> v;
    add(u, v);
    add(v, u);
  }
  int cnt = 0;
  for (int i = 1; i <= n; ++i) {
    if (!vis[i]) dfs(i), ++cnt;
  }
  cout << cnt << endl;
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("C - Count Connected Components.in", "r", stdin);
  freopen("C - Count Connected Components.out", "w", stdout);
#endif
#endif

  std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  return BlueQuantum::main();
}
